package com.qf.controller;

import com.qf.pojo.User;
import com.qf.service.UserService;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import javax.servlet.annotation.WebServlet;
import java.io.IOException;
import java.util.List;

/**
 * @author lixu
 */
@WebServlet(name = "DruidServlet",urlPatterns = "/hello")
public class DruidServlet extends javax.servlet.http.HttpServlet {

    protected void doPost(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws javax.servlet.ServletException, IOException {

    }

    protected void doGet(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws javax.servlet.ServletException, IOException {

        ApplicationContext ac =
                new ClassPathXmlApplicationContext("spring-context.xml");

        UserService bean = ac.getBean(UserService.class);
        List<User> userList = bean.findUser();
        for (User user : userList) {
            System.out.println(user);
        }

    }
}
